import React, { Component } from 'react'

class Control extends Component {
  state = {
    title: '受控组件',
    title1: '非受控组件',
  }
  // 创建ref对象
  titleRef = React.createRef()
  submit = (e) => {
    // 组织浏览器默认行为
    e.preventDefault()
    console.log(e)
  }
  render() {
    return (
      <div>
        <form onSubmit={this.submit}>
          <h1>0.3受控与非受控组件</h1>
          <div></div>
          <h1>04.非受控组件</h1>
          <div>
            title1:{this.state.title}
            <input type="text" ref={this.titleRef} />
            <button>获取input内容</button>
          </div>
        </form>
      </div>
    )
  }
}

export default Control
